const Mock = require('mockjs');
const { Random } = Mock;

function makeIns(ctx) {
    var list = [{
        "prdName": "苹果 iPhoneX",
        "id": "1001",
        "price": "5748.00",
        "disc": "5.8寸屏全面屏吃鸡手机",
        "store": "我就爱购数码专营店",
        "imgUrl": "https://img.alicdn.com/imgextra/i1/15381762/TB2CKXNlCYH8KJjSspdXXcRgVXa_!!0-saturn_solar.jpg_220x220.jpg"
    }, {
        "prdName": "苹果 iPhone 8",
        "price": "4788.00",
        "id": "1002",
        "disc": "全网通4G版 智能手机正品",
        "store": "绿森数码官方旗舰店",
        "imgUrl": "https://img.alicdn.com/imgextra/i3/13022581/TB2RNi9myQnBKNjSZFmXXcApVXa_!!0-saturn_solar.jpg_220x220.jpg"
    }, {
        "prdName": "苹果Phone8Plus",
        "id": "1003",
        "price": "3398",
        "disc": "港版三网4G秒发货",
        "store": "新园通讯数码",
        "imgUrl": "https://img.alicdn.com/imgextra/i3/117506104/TB2g3WmAQCWBuNjy0FaXXXUlXXa_!!0-saturn_solar.jpg_220x220.jpg"
    }, {
        "prdName": "三星 Galaxy S9",
        "price": "6699.00",
        "id": "1004",
        "disc": "4G手机",
        "store": "三星官方旗舰店",
        "imgUrl": "https://img.alicdn.com/imgextra/i3/15237275/TB2Oa4pFeySBuNjy1zdXXXPxFXa_!!0-saturn_solar.jpg_220x220.jpg"
    }, {
        "prdName": "荣耀10",
        "price": "2599",
        "id": "1005",
        "disc": "全面屏 全网通手机",
        "store": "华飞数码专营店",
        "imgUrl": "https://img.alicdn.com/imgextra/i2/41428892/TB2ab2xBrGYBuNjy0FoXXciBFXa_!!0-saturn_solar.jpg_220x220.jpg"
    }, {
        "prdName": "oppor15梦境",
        "price": "2999.00",
        "id": "1006",
        "disc": "正品全新oppor15",
        "store": "oppo酷炫专卖店",
        "imgUrl": "https://img.alicdn.com/imgextra/i1/23376660/TB2pRe.h3ZC2uNjSZFnXXaxZpXa_!!0-saturn_solar.jpg_220x220.jpg"
    }];
    var obj = list.filter(function(item){
        if (item.id == id) {
            console.log(item);
            return item
        } else {
            return false;
        }
    });
    var id = '1006';
    const data = {
       data: {
        ...obj[0],
        address: Random.county(true),
        stock: Random.integer(10,1000),
        capacity: Random.pick([64,128,32])
       },
        code: '666',
        msg: 'success'
    }
    ctx.body = data;
}
module.exports = makeIns;